import sys
import shutil
import os

def parseName(f):
    fs = f.split("-")
    return int(fs[1],16),fs[2].split(".")[1]

def newName(name):
    fs,end = parseName(name)
    nf = "np-08-%016x" % fs
    return nf+'.n'+end
    
for root, dirs, files in os.walk(sys.argv[1], topdown=False):
    for name in files:
        if "packn-" in name and ("no.pack" in name or "no.idx" in name):
            fn = os.path.join(root, name)
            nf = newName(name)
            print(fn,nf)
            shutil.copy(fn,os.path.join(sys.argv[2], nf))